The QuickUnzip method is nice for simple unzipping operations. For more sophisticated manipulation of an archive and its items, the Unzip method can be used. A compressed archive can be opened using the Open method. Individual items' properties, such as Password and Comment, can then be set. The items can then be extracted individually to a path or stream using the Unzip method of ArchiveItem. Or the archive as a whole can be extracted to a path using Unzip method of Archive.
C# |
Copy Code |
---|---|
//Alternatively, a compressed stream could have been opened archive1.Open("c:\\test.zip"); archive1.PreservePath = true; archive1.Overwrite = Overwrite.Always; archive1.Unzip("c:\\Test"); |
Visual Basic |
Copy Code |
---|---|
'Alternatively, a compressed stream could have been opened Archive1.Open("c:\test.zip") Archive1.PreservePath = True Archive1.Overwrite = Always Archive1.Unzip("c:\Test") |
C# |
Copy Code |
---|---|
if (archive1.Count > 1) { //Unzip the first item to a file, preserving its path archive1[0].Unzip("c:\\Test", true, Overwrite.Always); //Unzip the second item to a memory stream System.IO.MemoryStream stream = new System.IO.MemoryStream(); archive1[1].Unzip(stream); } |
Visual Basic |
Copy Code |
---|---|
If Archive1.Count > 1 Then 'Unzip the first item to a file, preserving its path Archive1(0).Unzip("c:\Test", True, Overwrite.Always) 'Unzip the second item to a memory stream Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream() Archive1(1).Unzip(stream) End If |
C# |
Copy Code |
---|---|
archive1.BeginQuickUnzip("c:\\test.zip", "c:\\Test", null); ... private void archive1_EndUnzip(object sender, Dart.PowerTCP.Zip.EndEventArgs e) { try { if (e.Exception == null) MessageBox.Show("Extraction Complete!"); else MessageBox.Show(e.Exception.Message); } catch {} } |
Visual Basic |
Copy Code |
---|---|
Archive1.BeginQuickUnzip("c:\test.zip", "c:\Test", Nothing) ... Private Sub Archive1_EndUnzip(ByVal sender As Object, ByVal e As Dart.PowerTCP.Zip.EndEventArgs) Handles Archive1.EndUnzip Try If (e.Exception Is Nothing) Then MessageBox.Show("Extraction Complete!") Else MessageBox.Show(e.Exception.Message) End If Catch End Try End Sub |
C# |
Copy Code |
---|---|
if (archive1.Count > 1) { //Unzip the first item to a file, preserving its path archive1[0].BeginUnzip("c:\\Test", true, Overwrite.Always, null); //Unzip the second item to a memory stream System.IO.MemoryStream stream = new System.IO.MemoryStream(); archive1[1].BeginUnzip(stream, null); } |
Visual Basic |
Copy Code |
---|---|
If Archive1.Count > 1 Then 'Unzip the first item to a file, preserving its path Archive1(0).BeginUnzip("c:\Test", True, Overwrite.Always, Nothing) 'Unzip the second item to a memory stream Dim stream = New System.IO.MemoryStream() Archive1(1).BeginUnzip(stream, Nothing) End If |